<?php

namespace App\Http\Common\nacos;

use App\Http\Common\nacos\entity\NamespaceServiceEntity;
use App\Http\Common\nacos\service\ConfigService;
use App\Http\Common\nacos\service\InstanceService;
use App\Http\Common\nacos\service\NamespaceService;

class NacosFactory
{
    public static function setConfig(string $class, array $params)
    {
        switch ($class) {
            case NamespaceService::class:
                $entity = new NamespaceServiceEntity();
                break;
            case ConfigService::class:
                break;
            case InstanceService::class:
                break;
        }

        $params = json_decode(json_encode($params));
        $jm = new \JsonMapper();
        call_user_func_array([new $class, 'set'], [$jm->map($params, $entity)]);
    }
}
